const commodity = function (Mock) {
  function getIndexCommodity() {
    let commodityList = Mock.mock({
      "array|10": [
        {
          "id": "@id",
          "image": "@image('100x100', @color)",
          "commodity_name": '@cword(5,15)',
          "score": '@float(0, 5, 1, 1)',
          "month_sales": '@integer(0, 10000)',
          "per_cost": '@integer(0, 100)',
          "min_price": '@integer(0, 100)',
          "shipping_price": '@integer(0, 50)',
          "distance": '@integer(0, 10000)',
          "time": '@integer(0, 120)',
        }
      ]
    }).array

    return {
      commodityList,
      code: 200,
    }
  }

  function getCommodityByCategory() {
    let commodityList = Mock.mock({
      "array|10": [
        {
          "id": "@id",
          "image": "@image('100x100', @color)",
          "commodity_name": '@cword(5,15)',
          "score": '@float(0, 5, 1, 1)',
          "month_sales": '@integer(0, 10000)',
          "per_cost": '@integer(0, 100)',
          "min_price": '@integer(0, 100)',
          "shipping_price": '@integer(0, 50)',
          "distance": '@integer(0, 10000)',
          "time": '@integer(0, 120)',
          "commend_list": Mock.mock({
            "array|3":[
              {
                "price": '@integer(0, 100)',
                "discount_price": '@integer(0, 100)',
                "image": "@image('100x100', @color)",
                "name": '@cword(5,15)',
              }
            ]
          }).array
        }
      ]
    }).array

    return {
      commodityList,
      code: 200,
    }
  }

  function getCommodityByStoreId(){
    let categoryList = Mock.mock({
      'array|5':[{
        'id': '@id',
        'name': '@cword(4, 8)',
        'commodityList': Mock.mock({
          'array|10': [{
            'id': '@id',
            'image': '@image("100x100", @color)',
            'name': '@cword(5, 10)',
            'price': '@float(1, 50, 1, 1)',
            'discountPrice': '@float(1, 50, 1, 1)',
            'monthSales': '@integer(1, 1000)',
            'likeRate': '@integer(1,100)',
            'discount': '@integer(1,10)',
          }]
        }).array
      }]
    }).array

    
    return {
      categoryList,
      code: 200,
    }
  }

  Mock.mock(/\/commodity\/index.*?/, 'get', getIndexCommodity)
  Mock.mock(/\/commodity\/getCommodityByCategory.*?/, 'get', getCommodityByCategory)
  Mock.mock(/\/commodity\/getCommodityByStoreId.*?/, 'get', getCommodityByStoreId)
}

export default commodity